package main

import (
	"context"
	"fmt"
	"gitee.com/alex_li/upload/cmd/upload/api"
	"gitee.com/alex_li/upload/internal/etc"
	"github.com/lishimeng/app-starter"
	"time"
)

func main() {

	defer func() {
		if err := recover(); err != nil {
			fmt.Println(err)
		}
	}()

	err := _main()
	if err != nil {
		fmt.Println(err)
	}
	time.Sleep(time.Millisecond * 200)
}
func _main() (err error) {

	application := app.New()

	err = application.Start(func(ctx context.Context, builder *app.ApplicationBuilder) (e error) {

		e = builder.LoadConfig(&etc.Config, nil)
		if e != nil {
			return
		}

		builder.
			SetWebLogLevel("debug").
			EnableWeb(etc.Config.Web.Listen, api.Router).
			PrintVersion()
		return
	})
	return
}
